/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.biz.entity;

import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.List;
import com.jeesite.common.collect.ListUtils;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.sys.entity.Area;
import com.jeesite.modules.sys.entity.Office;

/**
 * 订单表Entity
 * @author Lai_Hanzhang
 * @version 2019-03-13
 */
@Table(name="biz_order", alias="a", columns={
		@Column(name="id", attrName="id", label="主键", isPK=true),
		@Column(name="number", attrName="number", label="订单编号", queryType=QueryType.LIKE),
		@Column(name="type", attrName="type", label="订单类型 ", comment="订单类型 （0采购订单 1销售订单）"),
		@Column(name="name", attrName="name", label="订单名称", queryType=QueryType.LIKE),
		@Column(name="area", attrName="area.areaCode", label="订单区域"),
		@Column(name="biz_company_id", attrName="office.officeCode", label="对方公司"),
		@Column(name="order_money", attrName="orderMoney", label="订单金额"),
		@Column(name="order_state", attrName="orderState", label="订单状态 ", comment="订单状态 （0待对账  1待开票 2已开票 3已完成）"),
		@Column(name="logistics_status", attrName="logisticsStatus", label="物流状态 ", comment="物流状态 （0待发货 2已发货 3已签收）"),
		@Column(includeEntity=DataEntity.class),
	}, joinTable={
		@JoinTable(type=Type.LEFT_JOIN, entity=Office.class, alias="o", 
			on="o.office_code = a.biz_company_id",
		    columns={
		    	@Column(name="office_code", label="机构代码", isPK=true),
			    @Column(name="office_name",label="机构名称"),
			}),
		@JoinTable(type=Type.LEFT_JOIN, entity=Area.class, alias="b",
		on="b.area_code = a.area",
		columns={
				@Column(name="area_code", label="区域代码", isPK=true),
				@Column(name="area_name", label="区域名称", isQuery=false),
				@Column(name="area_type", label="区域类型"),
				@Column(name="tree_names", label="区域全称"),
	    }),
	}
    ,orderBy="a.update_date DESC"
)
public class BizOrder extends DataEntity<BizOrder> {
	
	private static final long serialVersionUID = 1L;
	private String number;		// 订单编号
	private String type;		// 订单类型 （0采购订单 1销售订单）
	private String name;		// 订单名称
	private Area area;		// 订单区域
	private Office office;		// 对方公司
	private String orderMoney;		// 订单金额
	private String orderState;		// 订单状态 （0待对账  1待开票 2已开票 3已完成）
	private String logisticsStatus;		// 物流状态 （0待发货 2已发货 3已签收）
	private List<BizOrderChild> bizOrderChildList = ListUtils.newArrayList();		// 子表列表
	
	
	public BizOrder() {
		this(null);
	}

	public BizOrder(String id){
		super(id);
	}
	
	
	@Length(min=0, max=50, message="订单编号长度不能超过 50 个字符")
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
	
	@NotBlank(message="订单类型 不能为空")
	@Length(min=0, max=50, message="订单类型 长度不能超过 50 个字符")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@NotBlank(message="订单名称不能为空")
	@Length(min=0, max=100, message="订单名称长度不能超过 100 个字符")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}
	
	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}
	
	@NotBlank(message="订单金额不能为空")
	@Length(min=0, max=50, message="订单金额长度不能超过 50 个字符")
	public String getOrderMoney() {
		return orderMoney;
	}

	

	public void setOrderMoney(String orderMoney) {
		this.orderMoney = orderMoney;
	}
	
	@NotBlank(message="订单状态 不能为空")
	@Length(min=0, max=50, message="订单状态 长度不能超过 50 个字符")
	public String getOrderState() {
		return orderState;
	}

	public void setOrderState(String orderState) {
		this.orderState = orderState;
	}
	
	@Length(min=0, max=50, message="物流状态 长度不能超过 50 个字符")
	public String getLogisticsStatus() {
		return logisticsStatus;
	}

	public void setLogisticsStatus(String logisticsStatus) {
		this.logisticsStatus = logisticsStatus;
	}
	
	public List<BizOrderChild> getBizOrderChildList() {
		return bizOrderChildList;
	}

	public void setBizOrderChildList(List<BizOrderChild> bizOrderChildList) {
		this.bizOrderChildList = bizOrderChildList;
	}

}